/** Online表单 扩展JSON 处理混入 */
export default {
  data() {
    return {
      // 扩展JSON
      extConfigJson: {},
    }
  },
  computed: {
    modelFullscreen() {
      return !!this.extConfigJson.modelFullscreen
    },
  },
  methods: {
    /** 解析扩展JSON */
    parseExtConfigJson(extConfigJson) {
      if (extConfigJson) {
        try {
          this.extConfigJson = JSON.parse(extConfigJson)
          // 判断是否开启了积木报表打印
          if (this.extConfigJson.reportPrintShow) {
            // 如果开启了，就触发事件，让父级列表页面可以打印
            this.$emit('can-print', this.extConfigJson.reportPrintUrl)
          }
        } catch (e) {
          console.error('online扩展JSON转换失败：', e)
        }
      }
    },
    /** 计算弹窗最小宽度 */
    calcModalMixWidth(width) {
      let minWidth = this.extConfigJson.modalMinWidth
      if (minWidth != null && minWidth !== '') {
        try {
          minWidth = Number.parseInt(minWidth)
          if (width < minWidth) {
            return minWidth
          }
        } catch {
          console.warn('error modalMinWidth value: ', minWidth)
        }
      }
      return width
    },
  },
}